package com.java.program_questions;

import java.util.Scanner;

/**
 * 问题：求s=a+aa+aaa+aaaa+aa...a的值，例如2+22+222+2222+22222
 * 分析：关键是计算出每一项的值
 */
public class Question8 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入两个整数：");
        int m = sc.nextInt(); // a
        int n = sc.nextInt(); // 几个数相加

        int[] a = new int[n];
        a[0] = m;
        int s = 0;

        for (int i = 1; i < n; i++) {
            m = m * 10 + 2;
            a[i] = m;
        }
        for (int i = 0; i < n; i++) {
            s += a[i];
        }
        System.out.print(s);
    }
}
